import {createRouter, createWebHashHistory} from 'vue-router'// 导入创建路由对象需要的函数
import Home from '../components/Home.vue'
import Add from '../components/Add.vue'
import List from '../components/List.vue'
import Update from '../components/Update.vue'

// 创建路由对象
const router = createRouter({
    history:createWebHashHistory(), //history属性用于记录路由的历史
    routes:[
        {
            path:"/home",
            component: Home 
        },
        {
            path:"/add",
            component: { // router的4.x版本不支持这么写了
                addView:Add
            }
        },
        {
            path:"/list",
            component: {
                listView:List
            }
        },
        {
            path:"/update",
            component: {
                updateView:Update
            }
        },
        {
            path:"/",
            component: Home
        },
        {
            path:"/showAll",
            redirect: '/list'
        }
    ]
})

export default router